package net.pimpas.context;

import java.util.Iterator;
import java.util.Locale;
import java.util.ResourceBundle;

import net.pimpas.core.context.FrameworkContext;
import net.pimpas.core.session.FrameworkSession;
import net.pimpas.session.DefaultFrameworkSession;
import net.pimpas.util.EqualsHelper;

import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 
 * @author pc
 *
*/

public class DefaultFrameworkContext implements FrameworkContext {

	private static final long serialVersionUID = -7270892997476342353L;
	private static final Locale DEFAULT_LOCALE = new Locale("en", "US");
	private FrameworkSession session;
	private Locale locale;
	
	public DefaultFrameworkContext() {
		this.setSession(new DefaultFrameworkSession());
		this.setLocale(DEFAULT_LOCALE);
	}

	public Locale getLocale() {
		return locale;
	}

	public ResourceBundle getResourceBundle() {
		return null;
	}

	public Iterator getResourcesBundle() {
		return null;
	}

	public FrameworkSession getSession() {
		return session;
	}

	public Iterator getSupportedLocales() {
		return null;
	}

	public void setSession(FrameworkSession session) {
		this.session = session;
	}
	
	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(this.getLocale())
			.append(this.getSession()).toHashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		return EqualsHelper.equals(this, obj);
	}

	private void setLocale(Locale locale) {
		this.locale = locale;
	}
}